<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>模块管理</title>
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	</head>
	<body class="easyui-layout" data-options="fit:true" style="overflow-y: hidden">
	<div data-options="region:'center',title:'模块管理'">
		<table id="moduleTree" class="easyui-treegrid"
			   data-options="
				url: '${app}/sysmgr/module/list.do',
				method: 'post',
				fitColumns: true,
				idField: 'module_id',
				treeField: 'module_name',
				toolbar: '#tb',
				onLoadSuccess: onLoadSuccess
			" style="width:100%;height:100%;">
			<thead>
			<tr>
				<th data-options="field:'module_name',width:100">模块名称</th>
				<th data-options="field:'module_id',width:30">模块编号</th>
				<th data-options="field:'module_url',width:115">模块地址</th>
				<th data-options="field:'operating',width:85,formatter:getBtn">操作</th>
			</tr>
			</thead>
		</table>
	</div>
	<div data-options="region:'east',title:'模块资源',split:true,collapsed:false" style="width:500px;">
		<div class="easyui-panel" fit="true" border="false" id="permitPanel"></div>
	</div>
	<div id="tb" style="height:auto">
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="parent.easyui.createWindow('模块新增', '${app}/sysmgr/module/edit.do', '750px', '330px', window.name);">新增</a>
	</div>
	</body>
    <script type="text/javascript">
		function getBtn(value, row, index) {
			return '<a href="javascript:;" class="easyui-linkbutton" onclick="parent.easyui.createWindow(\'模块修改\', \'${app}/sysmgr/module/edit.do?method=edit&moduleId='+row.module_id+'\', \'750px\', \'330px\', window.name);">编辑</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="loadPermit('+row.module_id+')">资源</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="moduleRole('+row.module_id+')">权限</a>&nbsp;'+
                	'<a href="javascript:;" class="easyui-linkbutton button-red" onclick="deleteModule('+row.module_id+')">删除</a>&nbsp;';
		}
		function onLoadSuccess(data){
			$('.easyui-linkbutton').linkbutton();
		}
		function reloadTree(){
			$('#moduleTree').treegrid('reload');
		}
		function deleteModule(moduleId){
			parent.easyui.confirm('系统提醒', '您确定要删除该条记录吗？', function(r){
				if (r){
					parent.layer.load(2);
					common.ajax('${app}/sysmgr/module/delete.do', 'moduleId='+moduleId,
						'POST', 'json', false,
						function(result){
							parent.layer.closeAll('loading');
							parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
							if (result.result == 1) {
								reloadTree();
							}
						}
					);
				}
			});
		}
		function loadPermit(moduleId){
			//$('.easyui-layout').layout('expand', 'east');
			$('#permitPanel').panel("refresh", "${app}/sysmgr/permit/frame.do?moduleId="+moduleId);
		}
		function moduleRole(moduleId){
			parent.easyui.createWindow('模块角色', '${app}/sysmgr/module/role.do?moduleId='+moduleId, '650px', '300px', window.name);
		}
    </script>
</html>